# Maintainer: AlexWMF <alexxwmf@gmail.com>

_realname=kqoauth
pkgbase=mingw-w64-${_realname}-qt4
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-qt4"
pkgver=0.98
pkgrel=3
pkgdesc="kQOAuth is a library written in C++ for Qt that implements the OAuth 1.0 authentication specification RFC 5849 (mingw-w64)"
arch=('any')
license=("custom:$pkgname")
url="https://github.com/kypeli/kQOAuth"
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
depends=("${MINGW_PACKAGE_PREFIX}-qt4")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=(strip staticlibs)
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/kypeli/kQOAuth/archive/${pkgver}.tar.gz"
        src_pro.patch
        pcfile_libname.patch)
sha256sums=('9d6c43d98bda559cf4fbb055843a46479e08381527a317edcd9823f2b4990671'
            '4325146b547eed6fe924203c23309ba727e1afc2aba637831e2eb277d2ea4bc2'
            'b0750e9fa0f6524adc056572001510420bee71e68504cd78228111f9f2dca3f5')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p0 -i ${srcdir}/src_pro.patch
  patch -p0 -i ${srcdir}/pcfile_libname.patch
}

build() {
  cd ${srcdir}/${_realname}-${pkgver}

  local _buildpkgdir=${pkgdirbase}/${pkgname}${MINGW_PREFIX}
  mkdir -p ${_buildpkgdir}
  local PREFIX_WIN=$(cygpath -am ${_buildpkgdir})

  pushd src > /dev/null
  ./pcfile.sh ${MINGW_PREFIX} ${pkgver}
  popd > /dev/null
  ${MINGW_PREFIX}/bin/qmake -d PREFIX=${PREFIX_WIN} kqoauth.pro

  make -j1 # VERBOSE=1
}

package() {
  cd ${srcdir}/${_realname}-${pkgver}
  make install
  mkdir -p ${pkgdir}${MINGW_PREFIX}/bin/
  mv "${pkgdir}${MINGW_PREFIX}"/lib/*.dll "${pkgdir}${MINGW_PREFIX}"/bin/
}
